﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AlbumDesigner.Helpers;

namespace Keepo.Models.Services
{
    public class PageLayoutExport
    {
        public PageLayoutExport() { }

        public PageLayoutExport(PageLayout pageLayout)
        {
            this.PageLayoutId = pageLayout.PageLayoutId;
            this.IsSingle = pageLayout.IsSingle;
            this.AlbumId = pageLayout.AlbumId ?? -1;
            this.Guid = pageLayout.Guid;

            this.ThumbnailUrl = AlbumHelper.PageLayoutThumbnailUrl(this.AlbumId, this.Guid);
            this.XmlUrl = AlbumHelper.PageLayoutXml(this.AlbumId, this.Guid);
        }

        public PageLayout toEntity()
        {
            PageLayout pageLayout = new PageLayout()
            {
                IsSingle = this.IsSingle,
                PageLayoutId = this.PageLayoutId,
                Guid = this.Guid
            };

            if (this.AlbumId != -1)
            {
                pageLayout.AlbumId = this.AlbumId;
            }
            else
            {
                pageLayout.AlbumId = null;
            }

            return pageLayout;
        }


        public int PageLayoutId { get; set; }
        public bool IsSingle { get; set; }
        public int AlbumId { get; set; }
        public string Guid { get; set; }
        public string ThumbnailUrl { get; set; }
        public string XmlUrl { get; set; }
    }
}